package com.mbc.controller;


import com.github.pagehelper.PageInfo;
import com.mbc.comment.Result;
import com.mbc.dto.ConditionDTO;
import com.mbc.dto.MbcBlackListDTO;
import com.mbc.dto.MbcBlackListInfoDTO;
import com.mbc.pojo.MbcBlackList;
import com.mbc.pojo.MbcBlackListInfo;
import com.mbc.service.BlackListService;
import com.mbc.vo.MbcBlackListInfoAndMbcBlackListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 黑名单表 前端控制器
 * </p>
 *
 * @author suimeng
 * @since 2024-04-15
 */
@RestController
@RequestMapping("/blackList")
@Api(tags = "黑名单接口")
@CrossOrigin
public class BlackListController {

    @Autowired
    private BlackListService blackListService;

    /**
     * 插入黑名单用户
     *
     * @param userId          用户 ID
     * @param mbcBlackListDTO MBC黑名单
     * @return {@link Result}<{@link Boolean}>
     */
    @PostMapping("/blackInsert/{userId}")
    @ApiOperation("新增举报人信息")
    public Result<Boolean> insertBlackUser(@PathVariable Integer userId, @RequestBody MbcBlackListDTO mbcBlackListDTO) {
        return Result.success(blackListService.insertBlackUser(userId, mbcBlackListDTO));
    }

    /**
     * 新增举报人详细信息
     *
     * @param userId              用户 ID
     * @param mbcBlackListInfoDTO MBC黑名单信息
     * @return {@link Result}<{@link Boolean}>
     */
    @PostMapping("/blackInfoInsert/{userId}")
    @ApiOperation("新增举报人详细信息")
    public Result<Boolean> insertInfoBlackUser(@PathVariable Integer userId,
                                               @RequestBody MbcBlackListInfoDTO mbcBlackListInfoDTO) {
        return Result.success(blackListService.insertInfoBlackUser(userId, mbcBlackListInfoDTO));
    }

    /**
     * 分页查询全部黑名单用户
     *
     * @param size 大小
     * @param page 页
     * @return {@link Result}<{@link Boolean}>
     */
    @GetMapping("/getBlack")
    @ApiOperation("分页查询全部黑名单用户")
    public Result<PageInfo<MbcBlackListInfoAndMbcBlackListVO>> getByBlackUser(@RequestParam(defaultValue = "1") Integer size,
                                                                              @RequestParam(defaultValue = "10") Integer page) {
        PageInfo<MbcBlackListInfoAndMbcBlackListVO> list = blackListService.getByBlackUser(size, page);
        return Result.success(list);
    }

    /**
     * 条件查询根据查询全部黑名单信息
     *
     * @param page         页
     * @param size         大小
     * @param conditionDTO 条件 DTO
     * @return {@link Result}<{@link List}<{@link MbcBlackListInfoAndMbcBlackListVO}>>
     */
    @GetMapping("/condition")
    @ApiOperation("条件查询根据查询全部黑名单信息")
    public Result<ArrayList<MbcBlackListInfoAndMbcBlackListVO>> getByConditionUserIdBlackUser(ConditionDTO conditionDTO, @RequestParam Integer page, @RequestParam Integer size) {
        ArrayList<MbcBlackListInfoAndMbcBlackListVO> list =
                blackListService.getByConditionUserIdBlackUser(conditionDTO, size, page);
        return Result.success(list);
    }

    /**
     * 更新黑名单信息
     *
     * @param userId          用户 ID
     * @param mbcBlackListDTO MBC 黑名单 DTO
     * @return {@link Result}<{@link Boolean}>
     */
    @PostMapping("/update/{userId}")
    @ApiOperation("更新黑名单信息")
    public Result<Boolean> updateBlackUser(@PathVariable Integer userId,@RequestBody MbcBlackListDTO mbcBlackListDTO){
       return Result.success(blackListService.updateBlackUser(userId,mbcBlackListDTO));
    }

    /**
     * 更新被举报人信息
     *
     * @param mbcBlackListInfoDTO MBC黑名单信息DTO
     * @param reasonsId           被举报人 ID
     * @return {@link Result}<{@link Boolean}>
     */
    @PostMapping("/updateInfo/{reasonsId}")
    @ApiOperation("更新被举报人信息")
    public Result<Boolean> updateBlackInfoUser(@PathVariable Integer reasonsId,@RequestBody MbcBlackListInfoDTO mbcBlackListInfoDTO){
        return Result.success(blackListService.updateBlackInfoUser(reasonsId,mbcBlackListInfoDTO));
    }
}
